package com.sdses.weather.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Data
@Component
@ConfigurationProperties(prefix = "weather.providers-request-mapping")
public class WeatherProviderProperties {

    private List<ReqRespConfig> providers = new ArrayList<>();
    private String appCode;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ReqRespConfig {
        private String requestURI;     // api对应的外部接口
        private int ttl = 300;     // 单位秒
        private String provider;     // 厂商名
        private String type;         // 请求类型
        private String url;          // API 地址 请求三方接口
        private String method = "POST";           // POST
        private String token;        // Token
        private Class<?> aClass; // 映射类的全限定名
        private Class<?> contextClass; // 映射类的全限定名
        //
        private String classPath; // 映射类的全限定名
        private String contextClassPath; // 映射类的全限定名
        private String appCode;

        public ReqRespConfig(String requestURI, int ttl ,String provider, String type, String url,
                             String method, String token, Class<?> aClass,
                             Class<?> contextClass, String appCode) {
            this.requestURI = requestURI;
            this.ttl = ttl;
            this.provider = provider;
            this.type = type;
            this.url = url;
            this.method = method;
            this.token = token;
            this.aClass = aClass;
            this.contextClass = contextClass;
            this.appCode = appCode;
        }
    }
}